package com.b2.controller.wx;

import com.b2.pojo.dto.CourseDto;
import com.b2.pojo.dto.CourseRecommendDto;
import com.b2.pojo.entity.Course;
import com.b2.result.Result;
import com.b2.service.CourseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/wx/Course")
@Api(tags = "课程相关接口")
@Slf4j
@CrossOrigin
public class WxCourseController {

    @Resource
    private CourseService courseService;


    @PostMapping("/list")
    @ApiOperation("根据课程权限查询所有课程")
    public Result<List<CourseDto>> selectList(@ApiParam("课程权限") @RequestParam(name = "courseAuthority")String courseAuthority){
        return courseService.selectList(courseAuthority);
    }

    @ApiOperation("查询推荐课程")
    @GetMapping("/recommendList")
    public Result<List<CourseRecommendDto>> recommendList(@ApiParam("null 所有推荐课程 1 热门课程 2 轮播图 3 热门课程和轮播图(默认查询）")
                                              @RequestParam("courseRecommend") Integer courseRecommend,
                                                          @ApiParam("课程权限") @RequestParam("courseAuthority") String courseAuthority) {
        return courseService.recommendList(courseRecommend, courseAuthority);
    }

}
